﻿using RpcCentral.Model.DB;
using RpcModel.Model;
using SqlSugarHelper;

namespace RpcCentral.DAL.Repository
{
    internal class ServerClientLimitDAL : IServerClientLimitDAL
    {
        private IRepository<ServerClientLimitModel> _Db;
        public ServerClientLimitDAL(IRepository<ServerClientLimitModel> db)
        {
            _Db = db;
        }


        public ServerClientLimit GetClientLimit(long rpcMerId, long serverId)
        {
            return this._Db.Get(c => c.RpcMerId == rpcMerId && c.ServerId == serverId, c => new ServerClientLimit
            {
                IsEnable = c.IsEnable,
                LimitNum = c.LimitNum,
                LimitTime = c.LimitTime,
                LimitType = c.LimitType,
                TokenInNum = c.TokenInNum,
                TokenNum = c.TokenNum
            });
        }
    }
}
